package com.pmgames.store.data
{
	import com.pmgames.store.data.ExtendedArrayCollection;
	import com.pmgames.store.components.TextComponent;

	public class RelationArrayCollection extends ExtendedArrayCollection
	{
		private var knownRelations:int;
		
		public function RelationArrayCollection(source:Array = null)
		{
			super(source);
			knownRelations = 0;
		}
				
		public function getKnownRelations():int
		{
			return knownRelations;
		}
		
		public function setKnownRelations(value:int):void
		{
			knownRelations = value;
		}
		
		public function incrementKnownRelations():void
		{
			knownRelations++;
		}
		public function matchRelation(relationSrc:TextComponent, relationDest:TextComponent):Boolean
		{
			for(var index:int = 0; index < this.length; index++)
			{
				var relationId1:Number = Number(relationSrc.id.substring(relationSrc.id.indexOf("-") + 1, relationSrc.id.length));
				var relationId2:Number = Number(relationDest.id.substring(relationDest.id.indexOf("-") + 1, relationDest.id.length));
				if(RelationItem(this.getItemAt(index)).equal(relationId1, relationId2)
				||RelationItem(this.getItemAt(index)).equal(relationId2, relationId1))
				{
					return true;
				}
			}
			return false;
		}
			
	}
}